package org.ghost.quickstart.scalac.collection

import org.ghost.quickstart.scalac.traits.BaseTrait

object IteratorLoop extends BaseTrait {
  override def print(): Unit = {
    val it = Iterator("Hello", "World", "呵呵", "测试")
    println("*****while迭代")
    while (it.hasNext) {
      println(it.next())
    }

    println("max求最大值:" + Iterator(10, 2, 87, 5, 47, 45, 84).max)
    println("min求最小值:" + Iterator(1, 57, 21, 45, 6, 1457, 8, 4).min)
    println("sum求和:" + Iterator(4, 57, 1, 6, 8, 45, 8, 4, 4, 5, 445, 0).sum)
    println("length,size求长度:" + Iterator(10, 2, 87, 5, 47, 45, 84).length + "," + Iterator(1, 57, 21, 45, 6, 1457, 8, 4).size)
  }
}
